import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";

@Entity('departments')
export class Department {
  @PrimaryGeneratedColumn()
  departmentId: number;

  @Column()
  departmentName: string;

  @Column()
  sort: number;

  @Column({
    nullable: true
  })
  parentId: number;

  @Column({
    nullable: true
  })
  parentName: string;

  @Column({
    nullable: true
  })
  description: string;

  @Column()
  updateTime: Date;

  @OneToMany(type => Department, department => department.children)
  parent: Department;

  @ManyToOne(type => Department, department => department.parent)
  children: Department[];
}
